package com.sunsys.cxf.services;

import javax.xml.ws.Endpoint;

import org.apache.cxf.jaxws.JaxWsServerFactoryBean;

public class Server {

    protected Server() throws Exception {
//        // START SNIPPET: publish
//        System.out.println("Starting Server");
//        HelloWorldImpl implementor = new HelloWorldImpl();
//        String address = "http://localhost:9000/helloWorld";
//        Endpoint.publish(address, implementor);
//        // END SNIPPET: publish
    	
    	
    	HelloWorldImpl implementation = new HelloWorldImpl();
    	JaxWsServerFactoryBean serverFactoryBean = new JaxWsServerFactoryBean();
    	serverFactoryBean.setServiceClass(HelloWorldImpl.class);
    	serverFactoryBean.setServiceBean(implementation);
    	serverFactoryBean.setAddress("http://localhost:9000/helloWorld");
    	serverFactoryBean.create();
    	
    	
    }

    public static void main(String args[]) throws Exception {
        new Server();
        System.out.println("Server ready...");

        Thread.sleep(5 * 60 * 1000);
        System.out.println("Server exiting");
        System.exit(0);
    }
}
